﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;

namespace IntelligentCMS
{
    public partial class profile : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (Session["UserID"] == null)
            {
                Response.Redirect("login.aspx");
            }

            userid = (long)Session["UserID"];

           
            /*
            if (CheckIfProfileExists())
            {

                CMSSave_BasicInfo.Operation = CMSSave.OPERATION_Update;
            }
            else
            {
                CMSSave_BasicInfo.Operation = CMSSave.OPERATION_Insert;
            }




            CMSTextBox FirstName = new CMSTextBox();
            FirstName.Name = "First Name";
            FirstName.Key = "FirstName";

            CMSTextBox LastName = new CMSTextBox();
            LastName.Name = "Last Name";
            LastName.Key = "LastName";

            CMSTextBox Address = new CMSTextBox();
            Address.Name = "Address";
            Address.Key = "Address";

            CMSTextBox City = new CMSTextBox();
            City.Name = "City";
            City.Key = "City";

            CMSTextBox State = new CMSTextBox();
            State.Name = "State";
            State.Key = "State";

            CMSTextBox Zip = new CMSTextBox();
            Zip.Name = "Zip";
            Zip.Key = "Zip";

            CMSTextBox Country = new CMSTextBox();
            Country.Name = "Country";
            Country.Key = "Country";

            CMSTextBox CellPhone = new CMSTextBox();
            CellPhone.Name = "CellPhone";
            CellPhone.Key = "CellPhone";

            CMSTextBox WorkPhone = new CMSTextBox();
            WorkPhone.Name = "WorkPhone";
            WorkPhone.Key = "WorkPhone";

            CMSTextBox HomePhone = new CMSTextBox();
            HomePhone.Name = "HomePhone";
            HomePhone.Key = "HomePhone";


            CMSSave_BasicInfo.Controls.Add(FirstName);
            CMSSave_BasicInfo.Controls.Add(LastName);
            CMSSave_BasicInfo.Controls.Add(Address);
            CMSSave_BasicInfo.Controls.Add(City);
            CMSSave_BasicInfo.Controls.Add(State);
            CMSSave_BasicInfo.Controls.Add(Zip);
            CMSSave_BasicInfo.Controls.Add(Country);
            CMSSave_BasicInfo.Controls.Add(CellPhone);
            CMSSave_BasicInfo.Controls.Add(WorkPhone);
            CMSSave_BasicInfo.Controls.Add(HomePhone);
            

            */
            

        }

        private long userid = -1;

        private bool CheckIfProfileExists()
        {

            /*
            CMSDbDataLayer newDataLayer = new CMSDbDataLayer(ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString, CMSDbDataHelper.Microsoft);
            // It puts the lotion on its skin, or else it gets the hose again. -> Silence of the Lambs.
            // It escapes the input with the string, or else it gets the sql-injection attack again! -> Next Tuesday, if you don't sanitize the input.
            newDataLayer.AddQuery("SELECT [ID] FROM [Profile] WHERE [UserID] = " + userid);
            newDataLayer.NonQuery = false;
            newDataLayer.Execute();

            if (newDataLayer.Data.Rows.Count <= 0)
            {
                return false;
            }
            */
            return true;

        }
    }
}
